<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="cn.company.bean.ProduceService"%>
<%@page import="cn.company.database.DBUtils"%>
<%@page import="cn.company.bean.Sort"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>网站后台管理系统</title>
<%
	String path = request.getContextPath();
	List<ProduceService> products = DBUtils.getProduceService();
	List<Sort> sorts = DBUtils.getSortsByModuleId(1);
%>
<script language="javascript" src="<%=path %>/OurHome/images/jquery.js"></script>
<link href="<%=path %>/OurHome/css/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"><!--
	function callback(msg){
		 document.getElementById("msg").innerHTML = msg;  
		 document.getElementById("path").value=msg;
	}

	function updateSortid(obj) {
		var obj = document.getElementById("sortid");

		for(var i=obj.options.length - 1;i>=0;i--){
		obj.options.remove(i);   
		}

		<%
		for(int i = 0;i < products.size();i++){
		%>
				obj.options.add(new Option("<%=products.get(i).getTopic() %>",<%=products.get(i).getId() %>));  
		<%
			}
		%>
	}
</script>
</head>
<body>
	<div id="mainDiv">
		<c:import url="../public/top.jsp" />
		<div id="centerDiv">
			<c:import url="../public/navigation.jsp"></c:import>
			<div id="right"> 
				<div id="current">&nbsp;&nbsp;&nbsp;&nbsp;当前位置: 产品服务</div>
				<div id="form">
					<P>&nbsp;</P>
					<fieldset>
						<legend>添加产品:</legend>
						<form action="<%=path %>/OurHome/uploadAttaches.jsp" method="post" enctype="multipart/form-data" target="uploadIframe">
							添加附件：<input type="file" name="upload"/>
							<input type="submit" value="上传"/><br>
							<span id="msg"></span>
						</form>
						<iframe name="uploadIframe" id="uploadIframe" style="display:none"></iframe>
						<form action="<%=path %>/OurHomeControlServlet" method="post">
							<input type="hidden" name="action" value="addproductservice" />
							<input type="hidden" name="path" id="path"/>
							标题：<input type="text" id="topic" name="topic" /><br>
							二级菜单：<input type="checkbox" id="secondMenu" name="secondMenu" onclick="updateSortid(this)"><br>
							分类:
							<select name="sortid" id="sortid">
								<%
									for(int i = 0;i < sorts.size();i++){
								%>
										<option value="<%=sorts.get(i).getId() %>"><%=sorts.get(i).getSortName() %></option>
								<%
									}
								%>
							</select><br>
							内容：<c:import url="../../jsp/demo2.jsp"></c:import>
							<input type="submit" value="提交内容" id="submit" name="submit"/>
						</form>
					</fieldset>
					<P>&nbsp;</P>
					<table border="1" cellpadding="0" cellspacing="0" style="border-color:#000000;">
						<tr bgcolor="#e8e8e0">
							<td width="30">编号</td>
							<td width="100">标题</td>
							<td width="200">图片路径</td>
							<td width="50" align="center">编辑</td>
							<td width="50" align="center">删除</td>
						</tr>
						<%
							for(int i = 0;i < products.size();i++){
							%>
							<tr>
								<td><%=i + 1 + "、" %></td>
								<td><%=products.get(i).getTopic() %></td>
								<td><%=products.get(i).getImagepath() %></td>
								<td align="center"><a href="<%=path %>/OurHome/product/updateproduct.jsp?id=<%=products.get(i).getId() %>">编辑</a></td>
								<td align="center"><a href="<%=path %>/OurHome/public/delete.jsp?id=<%=products.get(i).getId() %>&table=product&redirect=<%=path %>/OurHome/product/showproduct.jsp">删除</a></td>
							</tr>
							<%
							}
						%>
					</table>
					<p>&nbsp;</p>
				</div>
			</div>
		</div>
		<div id="bottomDiv"></div>
	</div>
	<script language="javascript">
		$("#test1").toggle(function(){$("#test").slideDown()},function(){$("#test").slideUp()})
	</script>
</body>
</html>
